package com.bwie.controller;

import com.bwie.pojo.TbProd;
import com.bwie.service.TbProdService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Wrj
 * @Date: 2025/4/24 19:38
 * @Description:
 **/
@RestController
@RequestMapping("/prod/index")
public class IndexController {

    @Autowired
    TbProdService tbProdService;

    @PostMapping("/getprodList")
    public R getprodList(@RequestBody PageInfoVo pageInfoVo){
        return tbProdService.getprodList(pageInfoVo);
    }
    @PostMapping("/addProd")
    public R addProd(@RequestBody TbProd tbProd){

        return tbProdService.addProd(tbProd);
    }

    @PostMapping("/getDictList/{typeId}")
    public R getDictList(@PathVariable(name = "typeId") Integer typeId){
        return tbProdService.getDictList(typeId);
    }

    @PostMapping("/deleteById/{prodId}")
    public R deleteById(@PathVariable(name = "prodId") Integer prodId){
        return tbProdService.deleteById(prodId);
    }

    @PostMapping("/updateById")
    public R updateById(@RequestBody TbProd tbProd){

        return tbProdService.updateprodById(tbProd);
    }

    /**
     * 发送卡夫卡消息
     * @param msg
     * @return
     */
    @PostMapping("/sendMessage/{msg}")
    public R sendMessage(@PathVariable(name = "msg") String msg){
        return tbProdService.sendMessage(msg);

    }

    @PostMapping("/changeProdStatus")
    public R changeProdStatus(@RequestBody TbProd tbProd){
        return tbProdService.changeProdStatus(tbProd);
    }
}
